package com.sunl.mall.common.api.topic;

import com.aliyun.openservices.ons.api.ExpressionType;
import com.aliyun.openservices.ons.api.PropertyKeyConst;

public enum MqTopic {
    /**
     * 测试普通消息
     */
    COMMON_MSG("topic_common_msg", "*", "普通消息"),

    /**
     * 顺序消息
     */
    ORDER_MSG("topic_order_msg", "*", "全局顺序消息"),
    ORDER_MSG_AREA("topic_order_msg_area", "*", "分区顺序消息"),

    DELAY_MSG("topic_delay_msg", "*", "定时/延时消息"),

    /**
     * 批量消息（底层还是普通消息，只是批量推送给自定义的订阅实现而已）
     * <p>
     * 具体的批量数量由这个参数设置{@link PropertyKeyConst#ConsumeMessageBatchMaxSize}
     */
    BATCH_MSG("topic_batch_msg", "*", "批量消息"),

    /**
     * 事务消息
     */
    PAY_SUCCESS_TRANSACTION("pay_success_transaction", "支付成功事务消息"),
    ;

    private final String topic;

    private final String type;

    private final String expression;

    private final String desc;

    MqTopic(String topic, String desc) {
        this.topic = topic;
        this.type = ExpressionType.TAG.name();
        this.expression = "*";
        this.desc = desc;
    }

    MqTopic(String topic, String expression, String desc) {
        this.topic = topic;
        this.type = ExpressionType.TAG.name();
        this.expression = expression;
        this.desc = desc;
    }

    /**
     * 铂金版可以使用 sql92 表达式，公网不能测试
     *
     * @param topic
     * @param type
     * @param expression
     * @param desc
     */
    MqTopic(String topic, String type, String expression, String desc) {
        this.topic = topic;
        this.type = type;
        this.expression = expression;
        this.desc = desc;
    }

    public String getTopic() {
        return topic;
    }

    public String getType() {
        return type;
    }

    public String getExpression() {
        return expression;
    }
}
